package com.ruoyi.industryfrontend.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.industryfrontend.domain.SpaceIndustry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.industryfrontend.domain.SpaceCollect;
import com.ruoyi.industryfrontend.service.ISpaceCollectService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 空间收藏Controller
 *
 * @author MagicCube
 * @date 2023-05-23
 */
@RestController
@RequestMapping("/collect")
public class SpaceCollectController extends BaseController
{
    @Autowired
    private ISpaceCollectService spaceCollectService;

    /**
     * 查询空间收藏列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SpaceCollect spaceCollect)
    {
        startPage();
        List<SpaceIndustry> list = spaceCollectService.selectSpaceCollectList(spaceCollect);
        return getDataTable(list);
    }

//    /**
//     * 导出空间收藏列表
//     */
//    @RequiresPermissions("industryfrontend:collect:export")
//    @Log(title = "空间收藏", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SpaceCollect spaceCollect)
//    {
//        List<SpaceCollect> list = spaceCollectService.selectSpaceCollectList(spaceCollect);
//        ExcelUtil<SpaceCollect> util = new ExcelUtil<SpaceCollect>(SpaceCollect.class);
//        util.exportExcel(response, list, "空间收藏数据");
//    }

//    /**
//     * 获取空间收藏详细信息
//     */
//    @RequiresPermissions("industryfrontend:collect:query")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(spaceCollectService.selectSpaceCollectById(id));
//    }

    /**
     * 新增空间收藏
     */
    @Log(title = "空间收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpaceCollect spaceCollect)
    {
        return toAjax(spaceCollectService.insertSpaceCollect(spaceCollect));
    }

//    /**
//     * 修改空间收藏
//     */
//    @RequiresPermissions("industryfrontend:collect:edit")
//    @Log(title = "空间收藏", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody SpaceCollect spaceCollect)
//    {
//        return toAjax(spaceCollectService.updateSpaceCollect(spaceCollect));
//    }

    /**
     * 删除空间收藏
     */
    @Log(title = "空间收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable String id)
    {
        return toAjax(spaceCollectService.deleteSpaceCollectById(id));
    }
}
